-
Notifications
You must be signed in to change notification settings - Fork 28
Keeper: Execute Steward operation immediately on epoch transition #204
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
### Problem - We have to get `RebalanceDirected` instructions through as fast as possible at the start of an epoch ### Solution - After executing every operation, the keeper check epoch info - If epoch transitioned, execute steward instructions (RebalanceDirected) immediately. Flow <img width="4224" height="3392" alt="image" src="https://github.com/user-attachments/assets/3d3626e7-5b94-47d3-96fd-f7a125736786" />
|
The logic here checks out but I do think that we can get even more aggressive with the timing. In this setup we will prioritize the directed rebalance next in the queue. The tasks in the queue can be quite heavy and there's potential for a non-trivial amount of time to pass before rebalance directed is removed from the queue. Curious to hear thoughts from others on maybe using something like the slot stream from a geyser RPC plugin on a separate task? Or is that overkill? @ebatsell @CoachChuckFF @mrmizz |
keepers/stakenet-keeper/src/main.rs
Outdated
| } | ||
| } | ||
|
|
||
| async fn check_and_fire_steward_on_epoch_transition( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The conditional here should actually be if the Stake Pool has updated, last_updated_epoch I think this is the field. Since increase/decrease commands are locked until that has completed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, changed the if condition
/// Check `last_update_epoch` field in Stake Pool
///
/// # Process
///
/// 1. Check the field `last_update_epoch` in StakePool account
/// 2. If the `last_update_epoch` has updated, trigger steward operation
/// 3. Otherwise, continue next operation
pub async fn check_last_update_epoch(
&mut self,
client: Arc<RpcClient>,
last_seen_epoch: &mut Option<u64>,
) -> bool {
if let Some(all_steward_accounts) = self.all_steward_accounts.as_ref() {
if let Ok(stake_pool) =
get_stake_pool_account(&client, &all_steward_accounts.stake_pool_address).await
{
if let Some(ref mut seen_epoch) = last_seen_epoch {
let has_updated = stake_pool.last_update_epoch > *seen_epoch;
*seen_epoch = stake_pool.last_update_epoch;
return has_updated;
} else {
*last_seen_epoch = Some(stake_pool.last_update_epoch);
return false;
}
}
}
false
}
Problem
RebalanceDirectedinstructions through as fast as possible at the start of an epochSolution
Flow changes